#ifndef svlTest_TEvents_H
#define svlTest_TEvents_H

#include "svl_TEvents.h"
namespace svlTest_TEvents {

///////////////////////////////////////////////////////////////////////////////

struct TComponent
{
  ////////////////////////////////////
  struct TEvents : public svl::TEvents
  {
    TEvents() {}
   ~TEvents() {}

    struct TEv0 : public TParam
    {
      TComponent &Sender;
      //
      TEv0(svl::TEventsList &EventsList,TComponent &sender) : TParam(EventsList),Sender(sender)
      {
      }
    };
    virtual void TEvents_Ev0(TParam &Param)
    {
      TEvents *P = (TEvents*)Param.GetPrev(); if (P) { P->TEvents_Ev0(Param);}
    }

    //
    virtual void TEvents_Ev1(TI &I,TComponent &Sender)
    {
      TEvents *P = (TEvents*)I.GetPrev();
      if (P) { P->TEvents_Ev1(I,Sender);}
    }
    //
    virtual void TEvents_Ev2(TI &I,TComponent &Sender)
    {
      TEvents *P = (TEvents*)I.GetPrev();
      if (P) { P->TEvents_Ev2(I,Sender);}
    }
  };
  ////////////////////////////////////////////
  struct TEventsList : public svl::TEventsList
  {
    TEventsList(TComponent &Sender) : svl::TEventsList(Default()),sender(Sender) {}
    //
    void Link  (TEvents &V) { svl::TEventsList::Link  (V);}
    void Unlink(TEvents &V) { svl::TEventsList::Unlink(V);}
    //
    TEvents &Get() { return (TEvents&)svl::TEventsList::GetBot();}

  private:
    static TEvents &Default() { static TEvents E; return E;}
    TComponent &sender;
  }
  Events;
  //
  TComponent() :Events(*this) {}
  //
  void Ev0() { Events.Get().TEvents_Ev0( TEvents::TEv0(Events,*this) );}
  //
  void Ev1() { Events.Get().TEvents_Ev1(svl::TEvents::TI(Events),*this);}
  void Ev2() { Events.Get().TEvents_Ev2(svl::TEvents::TI(Events),*this);}
};

///////////////////////////////////////////////////////////////////////////////
void Test();
///////////////////////////////////////////////////////////////////////////////
};

#endif
